package script;

import domain.User;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;


public class MethodSample {

    public static void main(String[] args) {

        User user = new User();
        ExpressionParser parser = new SpelExpressionParser();
        EvaluationContext context = new StandardEvaluationContext(user);

        String subString = parser.parseExpression("'Spring SpEl'.substring(7)").getValue(String.class);
        System.out.println(subString);
        Integer index = parser.parseExpression("'Spring SpEl'.indexOf('SpEl')").getValue(Integer.class);
        System.out.println(index);
        boolean isCorrect = parser.parseExpression("validatePassword('124')").getValue(context, Boolean.class);
        System.out.println(isCorrect);
        // 调用私有方法 发生错误
        // boolean isCorrect2 = parser.parseExpression("validatePassword2('124')").getValue(context, Boolean.class);
        // System.out.println(isCorrect2);
        boolean isCorrect3 = parser.parseExpression("validatePassword('124')").getValue(context, Boolean.class);
        System.out.println(isCorrect3);
        parser.parseExpression("addInterests('Js', 'C')").getValue(context, Boolean.class);



    }
}
